import audioop
import base64
import wave

import requests


with wave.open("/home/leo/Downloads/1717370065991598081.wav", "rb") as file:
    channels = file.getnchannels()
    fs = file.getframerate()
    data = file.readframes(file.getnframes())
    file.close()
    print(f'channels:{channels} fs:{fs}')
    #data = audioop.ulaw2lin(data,2)
    #url = "http://ability.ai.rmd.com.cn/book/search"
    url = "http://localhost:8080/book/search"
    myParams = {"robotId": 6, "fs": fs, "cid": "test01", "audioData": base64.b64encode(data)}
    res = requests.post(url=url, json=myParams)

    print('url:', res.request.url)  # 查看发送的url
    print("response:", res.text)  # 返回请求结果